# -*- coding:utf-8 -*-


class socketTin(object):  # socket管理
    users = {}

    def get(self, id):
        if id in self.users:
            return self.users[id]
        return None

    def save(self, id, socket):
        self.users[id] = socket

    def delete(self, id):
        del self.users[id]

    def num(self):
        return len(self.users)

    # redis列表名
    def redis_key_name(self, baId):
        """
        2017/8/1
        用于集中管理redis列表名，未实装
        因代码变动不易"""
        try:
            ks = self.users[baId]["redis_keys"]
            return ks
        except Exception, e:
            ks = {}
            ks["lb"] = baId  # 基站基本信息list
            ks["ss"] = "SS" + baId  # 待执行的有序集合(bell任务)
            ks["rl"] = "RL" + baId  # 已执行的任务列表(bell任务)
            self.users[baId]["redis-keys"] = ks
            return ks
